import java.awt.BorderLayout;
import java.awt.CardLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;



public class Settings {

	private PhoneLayout phone; // whole app screen (inc swipe right etc)
	
	private JButton backBut, quietestDayBut, busiestDayBut;
	
	private JPanel cards; // cards contains all screens
	

	
	public Settings(PhoneLayout phone){ // constructor set up panell
		this.phone = phone; // takes in the whole screen so it knows where to be assigned to
		cards = phone.cards;
		
		/* build full screen */
		JPanel settingsPanel = new JPanel();
		settingsPanel.setLayout(new BoxLayout(settingsPanel,BoxLayout.Y_AXIS));
		settingsPanel.setBackground(Color.white);
		settingsPanel.setMaximumSize(new Dimension(480,800));
		settingsPanel.setMinimumSize(new Dimension(480,800));
		settingsPanel.setPreferredSize(settingsPanel.getMaximumSize());
		
		
		/* build top navigation bar*/
		JPanel topBar = new JPanel(new BorderLayout());
		topBar.setBackground(Color.darkGray);
		topBar.setPreferredSize(new Dimension(480,80));
		settingsPanel.add(topBar);		
		
		JLabel title = new JLabel("   Options");
		title.setForeground(Color.white);
		title.setFont(new Font("Arial",Font.PLAIN,25));
		topBar.add(BorderLayout.WEST, title);
		
		/* top buttons */
		JPanel buttonPanel = new JPanel();
		buttonPanel.setLayout(new BoxLayout(buttonPanel,BoxLayout.X_AXIS));
		buttonPanel.setBackground(Color.darkGray);
		buttonPanel.setPreferredSize(new Dimension(100, 80));
		
		ButtonActionListener ButListener = new ButtonActionListener();

		backBut = new JButton(" Back ");
		backBut.addActionListener(ButListener);
		buttonPanel.add(backBut);
		
		topBar.add(BorderLayout.EAST, buttonPanel);	
		
	   /* build main screen THE MIDDLE WHITE BIT*/
		
		JPanel mainScreen= new JPanel(); 
		
		mainScreen.setBorder(new EmptyBorder(20,10,20,10)); // padding
		mainScreen.setBackground(Color.white);
		mainScreen.setPreferredSize(new Dimension(480,720));
		
		Font buttonFont = new Font("Arial",Font.PLAIN,20);
		
		Dimension buttonSize = new Dimension(460,80);
		quietestDayBut = new JButton("View Quietest Day");
		quietestDayBut.setFont(buttonFont);
		quietestDayBut.setPreferredSize(buttonSize);
		quietestDayBut.addActionListener(ButListener);
		busiestDayBut = new JButton("View Busiest Day");
		busiestDayBut.setFont(buttonFont);
		busiestDayBut.setPreferredSize(buttonSize);
		busiestDayBut.addActionListener(ButListener);
		
		mainScreen.add(quietestDayBut);
		mainScreen.add(busiestDayBut);

		
		
		settingsPanel.add(mainScreen);
		cards.add(settingsPanel, "settings");
	}
	

	
	
	class ButtonActionListener implements ActionListener{
		
		public ButtonActionListener(){
		}
		public void actionPerformed(ActionEvent ae) {	
			CardLayout cl = (CardLayout)(cards.getLayout());
			if (ae.getSource()==backBut){
				System.out.println("Cancel Button Pressed");
				cl.show(cards, "home");
			}
			else{
				System.out.println("Not yet implemented");
			}
		}

	}
}
